<template>
	<view class="page">
		<view class="group_2">
			<view class="d-flex flex-row align-center justify-center" style="height: 300rpx;background-color: #6a8cd9;">
				<view class="d-flex flex-column align-center justify-center">
					<view class="">
						<u-upload :fileList="fileList1" name="1" width="150rpx" height="150rpx" @afterRead="afterRead"
							@delete="deletePic" multiple :maxCount="1" />
					</view>
					<view class=""
						style="width: 160rpx;height: 50rpx;background: #d9ae2b;color: #ffffff;font-size: 24rpx;text-align: center;border-radius: 25rpx;margin-right: 20rpx;line-height: 50rpx;">
						人脸照片
					</view>
				</view>
			</view>

		</view>
		<view class="group_3">
			<!-- <text lines="1" class="text_8">分销员ID</text>
			<view class="item">
				<input type="text" placeholder="请输入分销员ID" class="atinput"  />
			</view> -->
			<text lines="1" class="text_8">姓名</text>
			<view class="item">
				<input type="text" placeholder="请输入姓名" class="atinput" />
			</view>
			<text lines="1" class="text_8">手机号</text>
			<view class="item">
				<input type="text" placeholder="请输入手机号" class="atinput" />
			</view>
			<!-- <text lines="1" class="text_8">地址</text>
			<view class="item">
				<pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
					<input class='atinput' v-model="regionName" type="text" 
						placeholder="请输入所在地区" disabled="" />
				</pick-regions>
			</view> -->


			<!-- 	<text lines="1" class="text_8">出生日期</text>
			<view class="item">
				<input type="text" placeholder="请输入出生日期" disabled v-model="userInfo.datatime" @click="show = true" class="atinput" />
			</view>
			<u-datetime-picker :show="show" v-model="value1" mode="date" @confirm="timelist"
				@cancel="show = false"></u-datetime-picker> -->
			<text lines="1" class="text_8">分销等级</text>
			<view class="item">
				<input type="text" placeholder="请选择分销等级" disabled v-model="userInfo.occupation_relation"
					@click="showoccupation = true" class="atinput" />
			</view>
			<u-picker :show="showoccupation" :columns="occupation_status" keyName="label" @confirm="addoccupation"
				@cancel="showoccupation = false">
			</u-picker>

			<text lines="1" class="text_8">佣金比例%</text>
			<view class="item">
				<input type="number" placeholder="请输入佣金比例" class="atinput" />
			</view>

			<text lines="1" class="text_8">许可截止日期</text>
			<view class="item">
				<input type="text" placeholder="请选择许可截止日期" disabled v-model="userInfo.data_time" class="atinput"
					@click="datashow = true" />
			</view>
			<u-calendar :show="datashow" mode="single" @confirm="confirmdata" @close="datashow = false"></u-calendar>

			<text lines="1" class="text_8">上级分销员</text>
			<view class="item">
				<input type="text" placeholder="请选择上级分销员" disabled v-model="userInfo.occupation_jineng"
					@click="showjineng = true" class="atinput" />
			</view>
			<u-picker :show="showjineng" :columns="jineng_status" keyName="label" @confirm="addjineng"
				@cancel="showjineng = false">
			</u-picker>


			<!-- <text lines="1" class="text_8">状态</text>
			<view class="item">
				<view style="margin-top: 36rpx;">
					<u-radio-group v-model="userInfo.insurance" @change="groupChange">
						<u-radio label="启用" :name="1" activeColor="#ec652b"/>
						<u-radio label="禁用" :name="2" customStyle="margin-left: 60rpx;" activeColor="#ec652b"/>
					</u-radio-group>
				</view>
			</view>

			<text lines="1" class="text_8">备注</text>
			<view class="item">
				<u-textarea v-model="value2" placeholder="请输入备注信息" maxlength='-1'></u-textarea>
			</view> -->

			<!-- <text lines="1" class="text_8">所属场馆</text>
			 <view class="item">
			 	<input type="text" placeholder="请选择场馆" disabled v-model="userInfo.occupation_changguan" @click="showchangguan = true" class="atinput" />
			 </view>
			  <u-picker :show="showchangguan" :columns="changguan_status" keyName="label"
			  	@confirm="addchangguan" @cancel="showchangguan = false">
			  </u-picker>
			  
			  <text lines="1" class="text_8">关联小程序</text>
			  <view class="item">
			  	<input type="text" placeholder="请选择小程序" disabled v-model="userInfo.occupation_xcx" @click="showxcx = true" class="atinput" />
			  </view>
			   <u-picker :show="showxcx" :columns="xcx_status" keyName="label"
			   	@confirm="addxcx" @cancel="showxcx = false">
			   </u-picker> -->

			<view class="" style="width: 100%;height: 10vh;">

			</view>
		</view>
		<!-- <button bindtap="onClick" class="button_3">
			保存
		</button> -->
		<view class="d-flex flex-row justify-space-between justify-center align-center"
			style="position: fixed;bottom: 0;height: 120rpx;background-color: #fff;width: 100%;padding: 0 8%;z-index: 99;">
			<view class="" @click="onClick"
				style="width: 100%;height: 80rpx;background: linear-gradient(0deg, rgba(214, 53, 53, 0.9), rgba(255, 64, 64, 0.93), rgba(250, 142, 142, 0.93));
				border-radius: 80rpx 80rpx;color: #ffffff;font-size: 24rpx;text-align: center;border-radius: 35rpx;line-height: 80rpx;">
				新增
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import pickRegions from '../components/pick-regions/pick-regions.vue'
	export default {
		components: {
			pickRegions
		},
		data() {
			return {
				fileList1: [],
				url_phone: '',
				fileList: [], //图片列表
				show: false,
				value1: Number(new Date()),
				showoccupation: false, //职业
				occupation_status: [], //职业
				showjineng: false, //技能等级
				jineng_status: [], //技能等级
				showchangguan: false, //所属场馆
				changguan_status: [], //所属场馆
				showxcx: false, //关联小程序
				xcx_status: [], //关联小程序
				occupation_list: [{
						id: 1,
						label: "金牌"
					},
					{
						id: 2,
						label: "银牌"
					},
					{
						id: 3,
						label: "铜牌"
					},
				],
				jineng_list: [{
						id: 1,
						label: "张珊"
					},
					{
						id: 2,
						label: "李四"
					},
					{
						id: 3,
						label: "王五"
					},
				],
				changguan_list: [{
						id: 1,
						label: "苏州体育中心"
					},
					{
						id: 2,
						label: "扬州奥体"
					},
					{
						id: 3,
						label: "绍兴奥体"
					},
					{
						id: 4,
						label: "南通体育中心"
					},
				],
				xcx_list: [{
						id: 1,
						label: "衡阳奥星"
					},
					{
						id: 2,
						label: "衡阳奥星"
					},
					{
						id: 3,
						label: "苏州课代表"
					},
				],
				userInfo: {
					occupation_relation: '',
					occupation_relation_id: '',
					occupation_jineng: '',
					occupation_jineng_id: '',
					occupation_changguan: "",
					occupation_changguan_id: "",
					occupation_xcx: '',
					occupation_xcx_id: '',
					insurance: '0',
					datatime: '',
				},
				datashow: false,
				defaultRegion: [],
				defaultRegionCode: '440113',
				defaultRegionCode: '',
				region: [],
			}
		},
		computed: {
			regionName() {
				// 转为字符串
				return this.region.map(item => item.name).join(' ')
			}
		},
		onLoad() {
			this.shuju()
		},
		methods: {
			// 获取选择的地区
			handleGetRegion(region) {
				// let province = {}
				this.region = region
				// this.ordersList.province = region[0].code
				// this.ordersList.city = region[1].code
				this.city = region[2].code
			},
			confirmdata(e) {
				console.log(e, 'eee')
				const dateArray = e;
				// const firstDate = dateArray[0]; // 获取第一个日期
				// const lastDate = dateArray[dateArray.length - 1]; // 获取最后一个日期
				// const rangeArray = [firstDate, lastDate];
				this.userInfo.data_time = dateArray[0]
				this.datashow = false
			},
			shuju() {
				this.occupation_status.push(
					this.occupation_list
				)
				this.jineng_status.push(
					this.jineng_list
				)
				this.changguan_status.push(
					this.changguan_list
				)
				this.xcx_status.push(
					this.xcx_list
				)
			},
			// 职业
			addoccupation(e) {
				this.userInfo.occupation_relation = e.value[0].label
				this.userInfo.occupation_relation_id = e.value[0].id
				this.showoccupation = false
			},
			addjineng(e) {
				this.userInfo.occupation_jineng = e.value[0].label
				this.userInfo.occupation_jineng_id = e.value[0].id
				this.showjineng = false
			},
			addchangguan(e) {
				this.userInfo.occupation_changguan = e.value[0].label
				this.userInfo.occupation_changguan_id = e.value[0].id
				this.showchangguan = false
			},
			addxcx(e) {
				this.userInfo.occupation_xcx = e.value[0].label
				this.userInfo.occupation_xcx_id = e.value[0].id
				this.showxcx = false
			},
			groupChange(n) {
				this.userInfo.insurance = n
			},
			timelist(value) {
				this.show = false
				let date = new Date(value.value);
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM; //月补0
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d; //天补0
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h; //小时补0
				let m = date.getMinutes();
				m = m < 10 ? ('0' + m) : m; //分钟补0
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s; //秒补0
				this.userInfo.datatime = y + '-' + MM + '-' + d
				return y + '-' + MM + '-' + d; //年月日
				return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s; //年月日时分秒
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: this.url_phone
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'https://sass-test.doit10019.com/api/upload/uploadOneImage', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							// user: 'test',
							project_id: getApp().globalData.projectId,
							app_id: this.$https.weixinAppId,

						},
						success: (res) => {
							let result = JSON.parse(res.data);
							this.url_phone = result.data.url
							setTimeout(() => {
								resolve(this.url_phone)
							}, 1000)
						}
					});
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		width: 100%;
		// height: 100vh;
		background-color: #EDF5F5;

		.group_3 {
			background-color: rgba(255, 255, 255, 1.000000);
			width: 710rpx;
			height: 100%;
			display: flex;
			flex-direction: column;
			margin: 20rpx 0 0 20rpx;

			.item {
				// padding: 29rpx 30rpx 30rpx;
				padding: 25rpx 30rpx 20rpx 30rpx;

				.atinput {
					// border: #EBECEE 1rpx solid;
					font-size: 24rpx;
					height: 60rpx;
					width: 600rpx;
					padding-left: 20rpx;
				}

				.item-title {
					color: rgb(153, 153, 153);
					font-size: 28rpx;
					font-weight: 500;
					margin-bottom: 20rpx;
				}

				.value {
					color: rgb(51, 51, 51);
					font-size: 28rpx;
					font-weight: 500;
				}

				.time-cell {
					color: rgb(51, 51, 51);
					font-size: 28rpx;
					font-weight: 500;
					justify-content: flex-start;

					.time {
						width: 49%;

						&:last-of-type {
							margin-left: 20rpx;
						}
					}
				}

				.week-list {
					display: grid;
					grid-template-columns: repeat(5, 1fr);
					grid-gap: 20rpx;
					position: relative;

					.week-item {
						padding: 15rpx 0;
						background-color: rgb(243, 243, 243);
						border-radius: 5rpx;
						text-align: center;
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						font-weight: 500;
						border: solid 2rpx transparent;
						box-sizing: border-box;
					}

					.active {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;

						// &:before {
						// 	display: block;
						// 	content: '';
						// 	position: absolute;
						// 	width: 27rpx;
						// 	height: 28rpx;
						// 	right: -2rpx;
						// 	bottom: -2rpx;
						// 	background-image: url("https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/46b1cc85fcb0fd76095daf823b7d2bb4a3235519.png");
						// 	background-repeat: no-repeat;
						// 	background-size: 100%;
						// }
					}

					.active1 {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;
					}

					.active2 {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;
					}

					.check {
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						position: absolute;
						bottom: 10rpx;
						right: 0;
					}
				}
			}
		}

		.text_2 {
			width: 93rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 15rpx 0 0 21rpx;
		}

		.section_2 {
			background-color: rgba(229, 229, 229, 1.000000);
			width: 672rpx;
			height: 1rpx;
			display: flex;
			flex-direction: column;
			margin: 40rpx 0 0 18rpx;
		}

		.text_3 {
			width: 47rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 42rpx 0 0 19rpx;
		}

		.text_4 {
			width: 82rpx;
			height: 26rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 24rpx 0 0 20rpx;
		}

		.section_3 {
			background-color: rgba(229, 229, 229, 1.000000);
			width: 672rpx;
			height: 1rpx;
			display: flex;
			flex-direction: column;
			margin: 40rpx 0 0 18rpx;
		}

		.text_5 {
			width: 47rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 39rpx 0 0 19rpx;
		}

		.text_6 {
			width: 82rpx;
			height: 26rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 24rpx 0 0 20rpx;
		}

		.section_4 {
			background-color: rgba(229, 229, 229, 1.000000);
			width: 672rpx;
			height: 1rpx;
			display: flex;
			flex-direction: column;
			margin: 40rpx 0 0 18rpx;
		}

		.text_7 {
			width: 95rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 39rpx 0 0 19rpx;
		}

		.image_2 {
			width: 151rpx;
			height: 151rpx;
			margin: 25rpx 0 0 18rpx;
		}


		.text_8 {
			width: 95rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 20rpx 0 0 19rpx;
		}

		.section_6 {
			width: 378rpx;
			height: 62rpx;
			flex-direction: row;
			display: flex;
			justify-content: space-between;
			margin: 26rpx 0 27rpx 21rpx;
		}

		.button_1 {
			background-color: rgba(243, 243, 243, 1.000000);
			height: 62rpx;
			display: flex;
			flex-direction: column;
			width: 174rpx;
		}

		.text_9 {
			width: 48rpx;
			height: 24rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 19rpx 0 0 63rpx;
		}

		.button_2 {
			background-color: rgba(255, 65, 5, 0.100000);
			height: 62rpx;
			display: flex;
			flex-direction: column;
			width: 174rpx;
		}

		.text_10 {
			width: 73rpx;
			height: 24rpx;
			overflow-wrap: break-word;
			color: rgba(255, 98, 0, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin: 19rpx 0 0 51rpx;
		}

		.button_3 {
			width: 90%;
			height: 80rpx;
			position: fixed;
			bottom: 20rpx;
			background: linear-gradient(0deg, rgba(214, 53, 53, 0.9), rgba(255, 64, 64, 0.93), rgba(250, 142, 142, 0.93));
			border-radius: 80rpx 80rpx;
			margin-left: 5%;
			color: #fff;
			font-size: 28rpx;
			z-index: 999;
		}
	}
</style>